package rad.framework.mda.generator.template.main.webapp.webinf;

import java.util.*;
import rad.framework.mda.generator.util.*;
import org.eclipse.uml2.uml.*;

public class Menus
{
  protected static String nl;
  public static synchronized Menus create(String lineSeparator)
  {
    nl = lineSeparator;
    Menus result = new Menus();
    nl = null;
    return result;
  }

  public final String NL = nl == null ? (System.getProperties().getProperty("line.separator")) : nl;
  protected final String TEXT_1 = "<ui:composition xmlns=\"http://www.w3.org/1999/xhtml\"" + NL + "\txmlns:ui=\"http://java.sun.com/jsf/facelets\"" + NL + "\txmlns:h=\"http://java.sun.com/jsf/html\" " + NL + "\txmlns:f=\"http://java.sun.com/jsf/core\"" + NL + "\txmlns:s=\"http://jboss.com/products/seam/taglib\"" + NL + "\txmlns:rich=\"http://richfaces.ajax4jsf.org/rich\">" + NL + "\t" + NL + "\t<rich:dropDownMenu id=\"HomeMenu\" " + NL + "\t\tvalue=\"#{messages['Home_Menu']}\"" + NL + "\t\trendered=\"#{s:hasRole('User')}\">" + NL + "\t\t" + NL + "\t\t<rich:menuItem id=\"MyWorkMenu\" " + NL + "\t\t\tvalue=\"#{messages['MyWork_Menu']}\"" + NL + "\t\t\trendered=\"#{s:hasRole('User')}\"" + NL + "\t\t\taction=\"#{worklist.findEntity}\">" + NL + "\t\t\t<s:conversationPropagation type=\"end\"/>" + NL + "\t\t</rich:menuItem>" + NL + "" + NL + "\t\t<ui:remove>" + NL + "\t\t<rich:menuItem id=\"DashboardMenu\" " + NL + "\t\t\tvalue=\"Dashboard\"" + NL + "\t\t\taction=\"/dashboard.xhtml\">" + NL + "\t\t\t<s:conversationPropagation type=\"end\"/>" + NL + "\t\t</rich:menuItem>" + NL + "\t\t</ui:remove>" + NL + "\t\t" + NL + "\t</rich:dropDownMenu>" + NL + "" + NL + "\t<ui:remove> " + NL + "\t<!--" + NL + "\t\tgroup by package or role ???" + NL + "\t\tmessage.properties" + NL + "\t\tplugin.xml" + NL + "\t\tpageflow init action or view id" + NL + "\t-->" + NL + "\t</ui:remove>" + NL + "\t" + NL + "\t<rich:dropDownMenu id=\"";
  protected final String TEXT_2 = "Menu\" " + NL + "\t\tvalue=\"#{messages['";
  protected final String TEXT_3 = "_Menu']}\"" + NL + "\t\trendered=\"#{s:hasRole('User')}\">";
  protected final String TEXT_4 = NL + NL + "\t\t<rich:menuItem id=\"";
  protected final String TEXT_5 = "Menu\" " + NL + "\t\t\tvalue=\"#{messages['";
  protected final String TEXT_6 = "_Menu']}\"" + NL + "\t\t\trendered=\"#{";
  protected final String TEXT_7 = "}\"" + NL + "\t\t\taction=\"find";
  protected final String TEXT_8 = "\">" + NL + "\t\t\t<s:conversationPropagation type=\"end\"/>" + NL + "\t\t</rich:menuItem>";
  protected final String TEXT_9 = NL + "\t</rich:dropDownMenu>" + NL + "" + NL + "\t<rich:dropDownMenu id=\"PageflowMenu\" " + NL + "\t\tvalue=\"Pageflows\"" + NL + "\t\trendered=\"#{s:hasRole('User')}\">";
  protected final String TEXT_10 = NL + NL + "\t\t<rich:menuItem id=\"";
  protected final String TEXT_11 = "Menu\" " + NL + "\t\t\tvalue=\"#{messages['";
  protected final String TEXT_12 = "_Menu']}\"" + NL + "\t\t\trendered=\"#{s:hasRole('User')}\"" + NL + "\t\t\taction=\"start";
  protected final String TEXT_13 = "\">" + NL + "\t\t\t<s:conversationPropagation type=\"end\"/>" + NL + "\t\t</rich:menuItem>";
  protected final String TEXT_14 = NL + NL + "\t</rich:dropDownMenu>" + NL + "\t" + NL + "\t<rich:dropDownMenu id=\"AdminMenu\" " + NL + "\t\tvalue=\"#{messages['Admin_Menu']}\"" + NL + "\t\trendered=\"#{s:hasRole('Admin')}\">" + NL + "" + NL + "\t\t<rich:menuItem id=\"UserMenu\" " + NL + "\t\t\tvalue=\"#{messages['User_Menu']}\"" + NL + "\t\t\trendered=\"#{s:hasRole('Admin')}\"" + NL + "\t\t\taction=\"findUser\">" + NL + "\t\t\t<s:conversationPropagation type=\"end\"/>" + NL + "\t\t</rich:menuItem>" + NL + "" + NL + "\t\t<rich:menuItem id=\"GroupMenu\" " + NL + "\t\t\tvalue=\"#{messages['Group_Menu']}\"" + NL + "\t\t\trendered=\"#{s:hasRole('Admin')}\"" + NL + "\t\t\taction=\"findGroup\">" + NL + "\t\t\t<s:conversationPropagation type=\"end\"/>" + NL + "\t\t</rich:menuItem>" + NL + "" + NL + "\t\t<rich:menuItem id=\"EventMenu\" " + NL + "\t\t\tvalue=\"#{messages['Event_Menu']}\"" + NL + "\t\t\trendered=\"#{s:hasRole('Admin')}\"" + NL + "\t\t\taction=\"findEvent\">" + NL + "\t\t\t<s:conversationPropagation type=\"end\"/>" + NL + "\t\t</rich:menuItem>" + NL + "" + NL + "\t\t<rich:menuItem id=\"TaskMenu\" " + NL + "\t\t\tvalue=\"#{messages['Task_Menu']}\"" + NL + "\t\t\trendered=\"#{s:hasRole('Admin')}\"" + NL + "\t\t\taction=\"findTask\">" + NL + "\t\t\t<s:conversationPropagation type=\"end\"/>" + NL + "\t\t</rich:menuItem>" + NL + "\t\t" + NL + "\t\t<rich:menuItem id=\"AuditEntryMenu\" " + NL + "\t\t\tvalue=\"#{messages['AuditEntry_Menu']}\"" + NL + "\t\t\trendered=\"#{s:hasRole('Admin')}\"" + NL + "\t\t\taction=\"findAuditEntry\">" + NL + "\t\t\t<s:conversationPropagation type=\"end\"/>" + NL + "\t\t</rich:menuItem>" + NL + "\t\t" + NL + "\t</rich:dropDownMenu>" + NL + "" + NL + "\t<ui:remove> " + NL + "\t\t<!-- accessed from parent tree by default -->";
  protected final String TEXT_15 = NL + NL + "\t\t<rich:menuItem id=\"";
  protected final String TEXT_16 = "Menu\" " + NL + "\t\t\tvalue=\"#{messages['";
  protected final String TEXT_17 = "_Menu']}\"" + NL + "\t\t\trendered=\"#{s:hasRole('User')}\"" + NL + "\t\t\taction=\"find";
  protected final String TEXT_18 = "\">" + NL + "\t\t\t<s:conversationPropagation type=\"end\"/>" + NL + "\t\t</rich:menuItem>";
  protected final String TEXT_19 = NL + NL + "\t</ui:remove>" + NL + "\t" + NL + "</ui:composition>";

  public String generate(Object argument)
  {
    final StringBuffer stringBuffer = new StringBuffer();
    
int order = 0;

    Model uml2Model = (Model) argument;
    stringBuffer.append(TEXT_1);
    stringBuffer.append(NameHelper.getCapName(uml2Model));
    stringBuffer.append(TEXT_2);
    stringBuffer.append(NameHelper.getCapName(uml2Model).replace("-","_"));
    stringBuffer.append(TEXT_3);
    for (Iterator i=ClassHelper.getClasses(uml2Model).iterator(); i.hasNext();) { org.eclipse.uml2.uml.Class element = (org.eclipse.uml2.uml.Class)i.next();
    if (!ClassHelper.hasSubclasses(element) && StereotypeHelper.isStereotypeApplied(element,"javax.persistence.Entity")) {
    if (!ClassHelper.isChild(element)) {
    stringBuffer.append(TEXT_4);
    stringBuffer.append(element.getName());
    stringBuffer.append(TEXT_5);
    stringBuffer.append(element.getName());
    stringBuffer.append(TEXT_6);
    stringBuffer.append(JsfHelper.getViewRoles(element));
    stringBuffer.append(TEXT_7);
    stringBuffer.append(element.getName());
    stringBuffer.append(TEXT_8);
    }
    }}
    stringBuffer.append(TEXT_9);
    for (Iterator<Region> i=JsfHelper.getPageflows(uml2Model); i.hasNext();) { Region region = (Region)i.next();
    stringBuffer.append(TEXT_10);
    stringBuffer.append(region.getName());
    stringBuffer.append(TEXT_11);
    stringBuffer.append(region.getName());
    stringBuffer.append(TEXT_12);
    stringBuffer.append(region.getName());
    stringBuffer.append(TEXT_13);
    }
    stringBuffer.append(TEXT_14);
    for (Iterator i=ClassHelper.getClasses(uml2Model).iterator(); i.hasNext();) { org.eclipse.uml2.uml.Class element = (org.eclipse.uml2.uml.Class)i.next();
    if (!ClassHelper.hasSubclasses(element) && StereotypeHelper.isStereotypeApplied(element,"javax.persistence.Entity")) {
    if (ClassHelper.isChild(element)) {
    stringBuffer.append(TEXT_15);
    stringBuffer.append(element.getName());
    stringBuffer.append(TEXT_16);
    stringBuffer.append(element.getName());
    stringBuffer.append(TEXT_17);
    stringBuffer.append(element.getName());
    stringBuffer.append(TEXT_18);
    }
    }}
    stringBuffer.append(TEXT_19);
    return stringBuffer.toString();
  }
}
